package practice;

/**
 * 编写Account类模拟银行储蓄账户。一个储蓄账户有账号、余额、年利息等属性，有存款、取款、查询方法。取款方法中，假设储蓄账户不允许透支。
 */

public class Account {
    // 金额，用户账号，年利率
    private double money;
    private int id;
    private double annual_interest;

    public Account( int id, double money, double annual_interest ) {
        this.id = id;
        this.money = money;
        this.annual_interest = annual_interest;
    }

    public static void main( String[] args ) {
        Account account = new Account(110, 100.00, 0.1);
        account.query();
        account.in(100);
        account.query();
        account.out(200.00);
        account.query();
    }

    public double in( double money ) {
        this.money += money;
        return this.money;
    }

    public double out( double money ) {
        if (money > this.money) {
            System.out.println("余额不足");
        } else {
            this.money -= money;
        }
        return this.money;
    }

    public void query() {
        System.out.println("账号：" + this.id + " 余额：" + this.money + " 利息：" + this.annual_interest);
    }

}
